home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4108 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: news.princeton.edu!blume
  2. From: blume@zayin.cs.princeton.edu (Matthias Blume)
  3. Newsgroups: comp.lang.c++,comp.lang.c
  4. Subject: Re: Performance: C vs. C++
  5. Date: 28 Jan 1996 02:25:23 GMT
  6. Organization: Princeton University
  7. Distribution: world
  8. Message-ID: <BLUME.96Jan27212523@zayin.cs.princeton.edu>
  9. References: <3105E9DC.1BE3@enermet.fi> <DLr46y.7rH@txnews.amd.com>
  10.     <BLUME.96Jan27152610@zayin.cs.princeton.edu>
  11.     <DLv2zC.A8z@research.att.com>
  12. NNTP-Posting-Host: zayin.cs.princeton.edu
  13. In-reply-to: ark@research.att.com's message of Sat, 27 Jan 1996 22:40:24 GMT
  14.  
  15. In article <DLv2zC.A8z@research.att.com> ark@research.att.com (Andrew Koenig) writes:
  16.  
  17.    If you try the exercise of taking a C++ program that makes
  18.    significant use of virtual functions and hand-translating it
  19.    to C, you may discover that this statement is no more true
  20.    [ ... than another bad comparison ... ]
  21.  
  22. You are right, and you are wrong.  It would be hard to translate a C++
  23. program into a C program by hand, because C++ is a horribly
  24. complicated language, with many gratuitous "features" that are
  25. supposed to make is "more efficient", and which on the other hand
  26. lacks some essential properties that every modern programming language
  27. should have.  The troubles you allude to are not so much due to the
  28. problems with virtual functions, they have a lot to do with the
  29. so-called "design" of the language as a whole.
  30.  
  31. I have written significant amounts of code in C, which make extensive
  32. use of function pointers.  Function pointers have been the least of my
  33. headache in such code.  When I write functional programs (which I do
  34. most of the time now), the use of functions as data has become even
  35. more second nature.
  36.  
  37. Also, in the foregoing discussion I haven't been suggesting you should
  38. hand-translate C++ code to C.  I merely pointed out, that the
  39. equivalent of virtual functions is not a "switch" (you will be hard
  40. pressed to show that you can hand-translate heavy "virtual" C++ code
  41. to C code using "switch" with more ease than using function pointers).
  42.  
  43. --
  44. -Matthias
  45.